import 'package:flutter/material.dart';

class ProductPage extends StatefulWidget {
  //Flutter2.2.0之后需要注意把Key改为可空类型  {Key? key} 表示key为可空类型
  ProductPage({Key? key}) : super(key: key);

  _ProductPageState createState() => _ProductPageState();
}

class _ProductPageState extends State<ProductPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text('商品页面'),
        ),
        body: Center(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              ElevatedButton(
                  child: Text("跳转到商品详情"),
                  onPressed: () {
                    Navigator.pushNamed(context, '/productinfo',
                        arguments: {"pid": 456});
                  }),
            ],
          ),
        ));
  }
}
